﻿
<extend name="Common/public"/>

<block name="content">
<title>用户管理</title>
</head>
<body>

<div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="member_add('添加用户','{:U('photoAdd',array('goods_id'=>$_GET['goods_id']))}','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加图片</a></span> <span class="r">共有数据：<strong id="count">{$count}</strong> 条</span> </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="80">ID</th>
				<th width="100">排序</th>
				<th width="40">大图</th>
				<th width="40">中图</th>
				<th width="90">缩略图</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<form>
			<volist name="goods_photo" id="v">
			<tr class="text-c">
				<td><input type="checkbox" value="{$v['id']}" name=""></td>
				<td>{$v['id']}</td>
				<td>{$v['sort']}</td>
				<td><img style="max-height: 120px;max-width: 120px;" src="{$v['big_image']}"/></td>
				<td><img style="max-height: 100px;max-width: 100px;" src="{$v['mid_image']}"/></td>
				<td><img style="max-height: 80px;max-width: 80px;" src="{$v['thumb_image']}"/></td>
				<td class="td-manage">
				 <a title="编辑" href="javascript:;" onclick="member_edit('编辑','{:U('photoAdd',array('photo_id'=>$v['id'],'goods_id'=>$_GET['goods_id']))}','4','','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
				 <a title="删除" href="javascript:;" onclick="member_del(this,'{:U('photoDel',array('photo_id'=>$v['id']))}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
			</tr>
			</volist>
			</form>
		</tbody>
	</table>
	</div>
</div>

<include file="Common/js"/>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

function datadel(){
	var ids = '';
	var count = 0;
	$('tbody input:checked').each(function(){
		ids += $(this).val()+',';
		count ++;
	});
	
	$.post('{:U("photoDel")}',{id:ids},function(data){
		if(data.status == 1){
			$('tbody input:checked').each(function(){
				$(this).parents("tr").remove();
			});
			layer.msg('已删除!',{icon:1,time:1000});
			$('#count').text(parseInt($('#count').text())-count);
		}else if(data.status == 2){
			layer.msg(data.msg);
		}else{
			layer.msg(data.msg,{icon:5,time:1000});
		}
	});
}

/*用户-添加*/
function member_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url,w,h);
}

/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*密码-修改*/
function change_password(title,url,id,w,h){
	layer_show(title,url,w,h);	
}
/*用户-删除*/
function member_del(obj,url){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: url,
			dataType: 'json',
			success: function(res){
				if(res == 1){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:1000});
					$('#count').text(parseInt($('#count').text())-1);
				}else{
					layer.msg('删除失败，请重试!',{icon:5,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script> 
</body>
</block>